package com.company.demo.factory_pattern;

public class StrategyFactory {
    Calculator calculator;

    public StrategyFactory() {
        calculator = new Calculator();
    }


    public void setOperater(String type) {
        switch (type) {
            case "+":
                calculator.setOperater(new Add());
                return ;
            case "-":
                calculator.setOperater(new Sub());
                return ;
            case "*":
                calculator.setOperater(new Mul());
                return ;
            case "/":
                calculator.setOperater(new Div());
                return ;
        }
        calculator.setOperater(null);
    }


    public double getResule(double numA, double numB) {
        calculator.setOperaterNumber(numA, numB);
        if (calculator != null) {
            return calculator.getResult();
        }
        return 0;
    }
}
